﻿package model.entity;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="Event")
public class Event {
	
	@Id
	@GeneratedValue(generator = "Event_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "Event_ID_Gen", sequenceName = "Event_SEQ_ID")
	private int id;
	
	@Column(nullable=false)
	private String name;
	private String description;
	
	@ManyToOne
	@JoinColumn(nullable=true)
	private MemberLevel designatedCusLv;
	
	@Column(nullable=false)
	private Date startDate;
	private Date endDate;
	private boolean ended;
	
	@OneToMany
	private List<Member> subscriptionList;
	private HashMap<String, Double> productDiscountRate;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public MemberLevel getDesignatedCusLv() {
		return designatedCusLv;
	}

	public void setDesignatedCusLv(MemberLevel designatedCusLv) {
		this.designatedCusLv = designatedCusLv;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public boolean isEnded() {
		return ended;
	}

	public void setEnded(boolean ended) {
		this.ended = ended;
	}

	public List<Member> getSubscriptionList() {
		return subscriptionList;
	}

	public void setSubscriptionList(List<Member> subscriptionList) {
		this.subscriptionList = subscriptionList;
	}

	public HashMap<String, Double> getProductDiscountRate() {
		return productDiscountRate;
	}

	public void setProductDiscountRate(HashMap<String, Double> productDiscountRate) {
		this.productDiscountRate = productDiscountRate;
	}

	public int getId() {
		return id;
	}
	
	@Override
	public String toString() {
		return "Event [id=" + id + ", name=" + name + ", description="
				+ description + ", designatedCusLv=" + designatedCusLv
				+ ", startDate=" + startDate + ", endDate=" + endDate
				+ ", ended=" + ended + ", subscriptionList=" + subscriptionList
				+ ", productDiscountRate=" + productDiscountRate + "]";
	}

	public double checkProductDiscount(String idP) {
		return 0;
	}

	public void addSubscription(Member m) {

	}

	public void removeSubscription(Member m) {

	}

	public void updateState() {

	}

}
